import { h } from 'vue'
import TableItem from './component/tableItem.vue'

export const defaultColumns = [{
    label: '日期',
    width: 120,
    align: 'center',
    fixed: 'left',
    prop: 'date'
  },
  {
    prop: 'username',
    label: '投手',
    minWidth: 120,
    fixed: 'left',
    align: 'center'
  },
  {
    prop: 'cost',
    label: '账户消耗(元)',
    minWidth: 120,
    fixed: 'left',
    align: 'center',
    render: row => {
      return h('span', (row.cost || 0).toFixed(2))
    }
  },
  {
    prop: 'realCost',
    label: '现金消耗(元)',
    minWidth: 120,
    fixed: 'left',
    align: 'center',
    render: row => {
      return h('span', (row.realCost || 0).toFixed(2))
    }
  },
  {
    prop: 'brokerage',
    label: '累计回收(元)',
    minWidth: 120,
    align: 'center',
    fixed: 'left',
    render: row => {
      return h('span', (row.brokerage || 0).toFixed(2))
    }
  },
  {
    prop: 'realBrokerage',
    label: '现金回收(元)',
    minWidth: 120,
    fixed: 'left',
    align: 'center',
    render: row => {
      return h('span', (row.realBrokerage || 0).toFixed(2))
    }
  },
  {
    prop: 'roi',
    label: '累计ROI',
    minWidth: 120,
    fixed: 'left',
    align: 'center',
    render: (row) => {
      return h('span', (row.roi).toFixed(2) + '%')
    }
  },
]

export const generatorColumns = () => {
  for (let i = 1; i <= 120; i++) {
    const key = `${i}roi`
    defaultColumns.push({
      label: `${i}日ROI/金额`,
      minWidth: 120,
      align: 'center',
      render: (row) => {
        return h(TableItem, {
          roi: (row[`${i}roi`] || 0) + '%',
          price: row[`${i}recharge`] || 0
        })
      }
    })
  }
  return defaultColumns
}
